<template>
  <div class="maincontent">
    <el-form :inline="true"  label-width="90px">
      <div class="maintitle">项目基本信息（市级项目）</div>
      <div class="formcontent">
        <div class="basicInformation">
          <span>项目名称：{{projCheckData.name}}</span>
          <span>项目编号：{{projCheckData.number}}</span>
          <span>项目级别：{{projCheckData.level == 0 ? '市级' : '区县级'}}</span>
          <span>图幅号：{{projCheckData.frameNumber}}</span>
        </div>
        <div class="basicInformation">
          <span>所属区县：{{projCheckData.district}}</span>
          <span>乡镇：{{projCheckData.countryside}}</span>
          <span>行政村：{{projCheckData.village}}</span>
        </div>
      </div>
      <div class="maintitle" style="margin:60px 0 30px 0;">建设信息</div>
      <div class="formcontent">
        <div class="basicInformation">
          <span>审定红线面积：{{checkData.redLine}}公顷</span>
          <span>实际建设总规模：{{checkData.totalSize}}公顷</span>
          <span>实际整新增耕地总面积：{{checkData.arableLandTotalArea}}公顷</span>
          <span>新增水田面积：{{checkData.paddyFieldArea}}公顷</span>
        </div>
        <div class="basicInformation">
          <span>新增旱地面积：{{checkData.dryLandArea}}公顷</span>
          <span>实际整新增整理耕地面积：{{checkData.arrangeArableLandArea}}公顷</span>
          <span>实际整新增开发耕地面积：{{checkData.developArableLandArea}}公顷</span>
          <span>实际整新增复垦耕地面积：{{checkData.reclamationArableLandArea}}公顷</span>
        </div>
      </div>
      <div class="maintitle" style="margin:60px 0 30px 0;">区县意见</div>
      <div class="titleDeputy">区县中心初审意见</div>
      <el-form-item>
        <el-input type="textarea" :rows="6" placeholder v-model="textarea" style="width:1000px;"></el-input>
      </el-form-item>
      <div>
        <el-form-item label="审查人">
          <el-input style="width:160px" v-model="name1" size="small"></el-input>
        </el-form-item>
        <el-form-item label="审查日期">
          <el-date-picker type="date" v-model="name2" size="small" style="width:160px"></el-date-picker>
        </el-form-item>
        <el-form-item label="审查意见">
          <el-select size="small" style="width:160px" v-model="name3">
            <el-option value="1" label="同意"></el-option>
            <el-option value="2" label="拒绝"></el-option>
          </el-select>
        </el-form-item>
      </div>

      <div class="titleDeputy">区县级审查意见</div>
      <el-form-item>
        <el-input type="textarea" :rows="6" placeholder v-model="textarea" style="width:1000px;"></el-input>
      </el-form-item>
      <div>
        <el-form-item label="审查人">
          <el-input style="width:160px" v-model="name1" size="small"></el-input>
        </el-form-item>
        <el-form-item label="审查日期">
          <el-date-picker type="date" v-model="name2" size="small" style="width:160px"></el-date-picker>
        </el-form-item>
        <el-form-item label="审查意见">
          <el-select size="small" style="width:160px" v-model="name3">
            <el-option value="1" label="同意"></el-option>
            <el-option value="2" label="拒绝"></el-option>
          </el-select>
        </el-form-item>
      </div>
      <div class="btn">
        <el-button type="primary">提交</el-button>
        <el-button>取消</el-button>
      </div>
    </el-form>
  </div>
</template>
 
<script> 
//引入requst
import { checkConsInfoF,addExaminationOpinion,checkExaminationOpinion} from '@/api/completionAcceptance/acceptance'
//引入公共方法
import {formatDateTime} from '@/utils/index'
export default {
  data() {
    return {
      name1: null,
      name2: null,
      name3: null,
      textarea: null,
      //竣工验收项目相关数据结构
      projCheckData:{
        name:null,//项目名称
        number:null,//项目编号
        district:null,//所属区县
        countryside:null,//所属乡镇
        village:null,//行政村
        year:null,//项目年度
        level:null,//项目级别;0:市级;1:区县级
        type:null,//项目类型
        frameNumber:null,//图幅号
        isStandard:null,//是否属于高标准基本农田项目:0:是;1:否
        duration:null,//项目工期
        recover:null,//投资回收期
      },
      //竣工验收提交数据
        // flag:null,//0:暂存;1:提交
      checkData:{
        additionArableLandArea: null,//减少建设用地而增加耕地面积
        afterArableLandArea: null,//整治后耕地面积
        afterArea: null,//整治后建设用地所占面积
        annexId: null,//附件id
        arableLandTotalArea: null,//实际整新增耕地总面积
        arrangeArableLandArea: null,//实际整新增整理耕地面积
        basicFarmlandScale: null,//计划建成高标准基本农田规模
        beforeArea:null,//整治前建设用地所占面积
        developArableLandArea:null,//实际整新增开发耕地面积
        developmentScale:null,//实际开发规模
        disasterArableLandArea:null,//灾毁耕地面积
        dryLandArea:null,//新增旱地面积
        farmlandDevelopScale:null,//实际基本农田开发规
        finishingScale:null,//实际整理规模
        occupyBalanceArea:null,//实际可用于占补平衡面积
        paddyFieldArea:null,//新增水田面积
        reclamationArableLandArea:null,//实际整新增复垦耕地面积
        reclamationScale:null,//实际复垦规模
        restoreArableLandArea:null,//灾后恢复耕地面积
        totalSize:null,//实际建设总规模
      },
      //验收日期
      time:{
        startTime:null,
        endTime:null,
      },
      projectId:1,//项目id（写死的）
      listLoading:false,//加载效果
    };
  },
  //初始化数据
  created(){},
  mounted(){
    this.getCheckInfo();//获取基本信息
    this.checkExaminationOpinionF();//调用区县审查意见
  },
  methods: {
      //查询实际建设信息以及项目信息
      getCheckInfo(){
          this.listLoading = true;
         let data = {
           projectId:this.projectId,
         };
				checkConsInfoF(data).then(res => {
          if(res.code == 1000){//成功
            this.listLoading = false;
            this.projCheckData = res.data.projectInfoDTO;//赋值项目基本数据
            this.checkData = res.data.actualConstructionInformationInfoDTO;//赋值验收人员基本数据
            // //赋值时间戳
            // if(res.data.completionAcceptanceInfoDTO.beginTime !== null){//开始时间
            //   this.time.startTime = new Date(res.data.completionAcceptanceInfoDTO.beginTime).getTime();//转换时间戳
            // }
            // if(res.data.completionAcceptanceInfoDTO.endTime !== null){
            //   this.time.endTime = new Date(res.data.completionAcceptanceInfoDTO.endTime).getTime();//转换时间戳
            // }
            // //转为字符串
            // if(res.data.completionAcceptanceInfoDTO.ending !== null){
            //   this.checkData.ending = res.data.completionAcceptanceInfoDTO.ending.toString();
            // }
          }
          console.log("调用成功",res,this.time.startTime,this.time.endTime)
        }).catch(err=>{
          console.log("报错",err)
        })
      },
      //查询审查意见、
      checkExaminationOpinionF(){
          // 添加意见 groupId 是第一个， type 是第二个。
          // 找到对应的框。值写死！
        let data = {
          groupId:18,//分组ID
          projectId:this.projectId,//项目ID
          type:0,//审查类型
        }
				checkExaminationOpinion(data).then(res => {
          if(res.code == 1000){//成功
            // this.projCheckData = res.data.projectInvestmentDTO;//赋值
          }
          console.log("调用成功",res)
        }).catch(err=>{
          console.log("报错",err)
        })
      },
      //添加审查意见
      addSubmit(){
        let data = {};
        //循环验证是否为空
        for(let i in this.checkData){
          if(this.checkData[i] == null){
            delete this.checkData[i]
          }
        }
        data = this.checkData;
        data.projectId= this.projectId;
        data.flag = 1;//提交
				addExaminationOpinion(data).then(res => {
          if(res.code == 1000){//成功
            this.projCheckData = res.data.projectInvestmentDTO;//赋值
          }
          this.$message({
            message:'提交成功',
            type:'success',
            
          })
          console.log("调用成功",res)
        }).catch(err=>{
          console.log("报错",err)
        })
      },
      //上传文件
      getreport(res, file, fileList){
        if(res.msg.indexOf("认证失败") !== -1){
            return this.$message({
                  message: "认证失败，重新上传",
                  type: 'error'
                });
        }
        //赋值附件id
        this.checkData.annexId = res.id;
        console.log("==============>",res, file, fileList)
      },
      changTime(){
        if(this.time.startTime !== null){
          this.checkData.beginTime = formatDateTime(this.time.startTime);//2019-11-12 2:00:9转换格式
        }else{
          this.checkData.beginTime = null;//初始化数据
        }
        if(this.time.endTime !== null){
          this.checkData.endTime = formatDateTime(this.time.endTime);//2019-11-12 2:00:9转换格式
        }else{
          this.checkData.endTime = null;//初始化数据
        }
      },
  }
};
</script>


<style lang="scss" scoped>
.maincontent {
  margin-top: 30px;
  padding: 30px 40px;
  background: #fff;
  height: auto;
  .maintitle {
    font-size: 18px;
    font-family: PingFang SC;
    font-weight: bold;
    line-height: 25px;
    color: #4d4d4d;
  }
  .formcontent {
    margin-top: 30px;
    .basicInformation {
      font-size: 14px;
      font-family: PingFang SC;
      font-weight: 500;
      line-height: 20px;
      color: #8c8c8c;
      margin-bottom: 20px;
      span {
        margin-right: 60px;
      }
    }
  }
}
.titleDeputy {
  padding: 0 0 10px 0;
  font-size: 14px;
  font-family: PingFang SC;
  line-height: 25px;
  color: #4d4d4d;
}
</style>